package com.cos.hospital.ui.usercenter;

import android.view.View;
import android.widget.ImageView;

import com.cos.hospital.R;
import com.cos.hospital.dao.HelperInfoDb;
import com.cos.hospital.dao.beandao.DbInfo;
import com.cos.hospital.init.BaseActivity;
import com.cos.hospital.tool.SPUtil;
import com.cos.hospital.tool.UTxt;
import com.cos.hospital.tool.glide.UGlide;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @Description: 我的二维码
 * @Author: Kosmos
 * @Date: 2018年9月12日 23:46
 * @Email: KosmoSakura@foxmail.com
 */
public class UserCodeActivity extends BaseActivity {
    @BindView(R.id.qr_bg)
    ImageView iBg;
    @BindView(R.id.qr_avatar)
    ImageView iAvatar;
    @BindView(R.id.qr_code)
    ImageView iCode;

    @Override
    protected int layout() {
        return R.layout.activity_user_code;
    }

    @Override
    protected void init() {
        UGlide.loadImage(this, R.mipmap.bg_qrcode, iBg);
    }

    @Override
    protected void logic() {
        DbInfo info = HelperInfoDb.SearchById(this, SPUtil.getUserId());
        if (info != null) {
            UGlide.loadRound(this, UTxt.isNull(info.getWxaCode()), iCode);
            UGlide.loadAvatar(context, UTxt.isNull(info.getAvatar()), iAvatar);
        }
    }

    @OnClick({R.id.title_back_pic})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_back_pic:
                finish();
                break;
        }
    }
}
